<template>
	<view>
		<view class="nav2">
			<u-navbar title="草稿箱" bgColor="transparent" autoBack :fixed="false"></u-navbar>
		</view>
		<view class="m30">
			<view class="flex-jus flex-start flex-wrap">
				<view class="bgFff list-item mb20 box_shadow" v-for="(item,index) in list" :key="index">
					<view class="list-img" @click="nologinJump('/subpage/you/release?id='+item.id+'&type='+item.resType)">
						<image :src="api_host + item.coverIcon" mode=""></image>
					</view>
					<view class="p20">
						<view class="textoverflow f26 c343 bold">{{item.title}}</view>
						<view class="flex-jus">
							<text class="f24 c999">{{item.createTime}}</text>
							<u-icon name="trash" size="18" @click="delItem(item)"></u-icon>
						</view>
					</view>
				</view>
			</view>
		</view>
		<u-modal :show="show_action" title="确认删除？">
			<view class="flex-jus" slot="confirmButton">
				<view class="flex1">
					<view class="mr20">
						<u-button color="#f7f7f7" :customStyle="{'color':'#111','height':'80rpx'}" shape="circle"
							@click="show_action = false">取消</u-button>
					</view>
				</view>
				<view class="flex1">
					<view class="ml20">
						<u-button color="#FFDE6D" :customStyle="{'color':'#111','height':'80rpx'}" shape="circle"
							@click="delVlogbtn()">确认</u-button>
					</view>
				</view>
			</view>
		</u-modal>
	</view>
</template>

<script>
	import {getDraft,delVlog} from '@/common/api_wan.js'
	export default {
		name: '',
		data() {
			return {
				show_action: false,
				sel_data:{},
				list: []
			}
		},
		onLoad(option) {
			
		},
		onShow() {
			this.getDraft()
		},
		methods: {
			async getDraft() {
				uni.showLoading()
				const res = await getDraft()
				if (res.code == 200) {
					this.list = res.data
					uni.hideLoading()
				}
			},
			delItem(item) {
				this.sel_data = item
				this.show_action = true
			},
			async delVlogbtn() {
				uni.showLoading({
					mask: true
				})
				const res = await delVlog({
					id: this.sel_data.id
				})
				if (res.code == 200) {
					this.sel_data = {}
					this.show_action = false
					this.getDraft()
				}
				uni.hideLoading()
			}
		}
	}
</script>

<style lang="scss" scoped>
	page {
		background-color: #FEF4E8;
	}

	.list-item {
		width: 48%;
		border-radius: 30rpx;
		.list-img {
			image {
				width: 100%;
				height: 320rpx;
				border-radius: 30rpx 30rpx 30rpx 0;
			}
		}
	}
</style>